package org.lex.ftp.ui.logging;

import org.lex.net.log.LogUnit;
import org.lex.net.log.ui.LogFormatter;

public class SimpleLogFormatter implements LogFormatter {
	public String format(LogUnit unit) {
		return clean(unit.getMessage());
	}

	private String clean(Object msg) {
		if (null == msg)
			return "";
		String str = msg.toString();
		int len = str.length();
		char ch = str.charAt(len - 1);
		if ('\r' == ch || '\n' == ch)
			return str;
		return str + "\n";
	}
}
